<?php 
header("content-type:text/html;charset=utf8");
//从redis中取出code
$redis=new redis();
//连接
$redis->connect("127.0.0.1","6379");
//接值
$u_tel=$_POST["u_tel"];
$u_name=$_POST["u_name"];
$u_pwd=$_POST["u_pwd"];
$code=$_POST["code"];
$rediscode=$redis->get("code".$u_tel);
if($rediscode)
{
	if($rediscode==$code)
	{
      //连接库
	  $db=new PDO("mysql:host=127.0.0.1;dbname=bj07c;charset=utf8","root","root");
	  $sql="insert into users value(null,'$u_name','$u_pwd','$u_tel',1)";
	  $res=$db->exec($sql);
	  if($res)
	  {
        $arr=array("code"=>1,"msg"=>"注册成功");
	  }
	  else
	  {
	  	$arr=array("code"=>2,"msg"=>"注册失败");
	  }
	}
	else
	{
		$arr=array("code"=>3,"msg"=>"验证码输入错误");
	}
}
else
{
	$arr=array("code"=>3,"msg"=>"验证码失效");
}

echo json_encode($arr);
 ?>